package dao;

import entity.School;
import factory.DaoFactory;
import util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;

public class SchoolService {
    SchoolDaoImpl schoolDaoImpl= DaoFactory.getDao(SchoolDaoImpl.class,"SchoolDaoImpl");
    public boolean add(School school) throws SQLException {
        Connection connection = JdbcHelper.getConn();
        boolean added=schoolDaoImpl.add(connection,school);
        JdbcHelper.close(connection);
        return added;
    }
    public boolean delete(int id) throws SQLException {
        Connection connection = JdbcHelper.getConn();
        boolean deleted=schoolDaoImpl.delete(id);
        JdbcHelper.close(connection);
        return deleted;
    }
    public boolean update(School school) throws SQLException {
        Connection connection = JdbcHelper.getConn();
        boolean updated=schoolDaoImpl.update(connection,school);
        JdbcHelper.close(connection);
        return updated;
    }
}
